<%@ page language="java" pageEncoding="utf-8"%>
<%
	String ct = request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport"
	content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="apple-touch-icon-precomposed" href="images/todolist.png" />
<link rel="apple-touch-startup-image" href="images/todo-splash.png" />
<title>ToDo App</title>
<link rel="stylesheet" type="text/css" href="<%=ct%>/css/tablet.css">
<link type="text/css" href="<%=ct%>/css/demo.css" rel="stylesheet">
<script type="text/javascript"
	src="<%=ct%>/dojo/dojox/mobile/deviceTheme.js"
	data-dojo-config="mblThemeFiles:['@theme',['demos/todoApp','todo']]"></script>

<script type="text/javascript" src="<%=ct%>/dojo/dojo/dojo.js"
	data-dojo-config="parseOnLoad: true,
				mblHideAddressBar: false,
				mblAndroidWorkaround: false,
				mblAlwaysHideAddressBar: false,
				app: {debugApp: 0},  // set debugApp to log app transtions and view activate/deactivate
				mvc: {debugBindings: 0},  // set on to debug mvc data bindings
				async: 1">
		</script>
<title>薪酬通-薪资查询</title>
<script language="JavaScript" type="text/javascript">
		var amount=0;
		require([
           "dojo/dom",
           "dojo/on",
     	   "dojo/_base/array",
    	   "dojo/ready",
    	   "dijit/registry",
    	   "dojox/mobile/ListItem",
            "dojo/dom-construct" ,
            "dojox/mobile/ListItem2",
    	   "dojox/mobile/parser",
    	   "dojox/mobile/Button",
			"dijit/_base/manager",  // dijit.byId
			"dojox/mobile",
			"dojox/mobile/compat",
			"dojox/mobile/parser",
			"dojox/mobile/Opener",
			"dojox/mobile/SpinWheelDatePicker"
		],function(dom,on, arr, ready, registry, ListItem,domconstruct,ListItem2){
			 ready(function() {
				 document.getElementById("maincontent").style.display="block";
				 document.getElementById("loading").style.display="none";
				 var myButton = dom.byId("searchbutton");
				 on(myButton, "click", function(evt){
					  registry.byId("home").performTransition("searchview", 1, "slide");
				  });
				 var params = {
						 operation:"neworderlist"
						};

					dojo.xhrGet({
				               url:'<%=ct%>/listOrderAction.do',
				               content:params,
				               handleAs: "json",
				               load: resultCallback,
				               error: resultError
				                });
					});


		function resultCallback(data,ioArgs) {
			var salarylist = registry.byId("neworderlist");
			arr.forEach(salarylist.getChildren(), function(child){
				salarylist.removeChild(child);
			});
			arr.forEach(data, function(item, i){
				var li = new ListItem2({
					onClick: getdetail,
					moveTo: "orderDetail",
				//	rightText:item.salaryMonth,
					//icon:'img/tab-icon-11h.png',
					item:item

				});
                var _d1=domconstruct.create("div",{
                      style:{
                         display:"block"
                      }
                });
                var _span1=domconstruct.create("span");
                var _span2=domconstruct.create("span");
                _span1.innerText="下单时间:";
                _span2.innerText=item.recorddate!=null?item.recorddate.substr(0,10):item.recorddate;
                _d1.appendChild(_span1);_d1.appendChild(_span2);

                var _d2=domconstruct.create("div");
                var _span3=domconstruct.create("span");
                var _span4=domconstruct.create("span",{
                    style:{
                        display:"inline",
                        
                     }
                });
                var _span5=domconstruct.create("span",{
                    style:{
                        display:"inline",
                        marginLeft:"30px"
                     }
                });
                var _span6=domconstruct.create("span");
                _span3.innerText="下单人：";
                _span4.innerText=item.recorder;
                _span5.innerText="状态：";
                _span6.innerText=item.orderflag;
                _d2.appendChild(_span3);_d2.appendChild(_span4);
                _d2.appendChild(_span5);_d2.appendChild(_span6);

                var _d3=domconstruct.create("div");
                var _span7=domconstruct.create("span");
                var _span8=domconstruct.create("span");
                var _span9=domconstruct.create("span",{
                    style:{
                        display:"inline",
                        marginLeft:"25px"
                     }
                });
                var _span10=domconstruct.create("span");
                _span7.innerText="付款方式：";
                _span8.innerText=item.recorder;
                _span9.innerText="订单类型：";
                _span10.innerText=item.ordertype;
                _d3.appendChild(_span7);_d3.appendChild(_span8);
                _d3.appendChild(_span9);_d3.appendChild(_span10);
				li.labelNode.innerHTML = item.suppliername;
                li.domNode.appendChild(_d1);
                li.domNode.appendChild(_d2);
                li.domNode.appendChild(_d3);
				salarylist.addChild(li);
			});
		}

		function getdetail(item){
			var detail = registry.byId("detail");
			// remove anything from previous selected stock
			arr.forEach(detail.getChildren(), function(child){
				detail.removeChild(child);
			});
			orderno=this.item.orderno;
			var li = new ListItem({
				rightText:this.item.orderno ,

			});
			li.labelNode.innerHTML = "订单号：";
			detail.addChild(li);

			var li1 = new ListItem({
				rightText:this.item.suppliercode ,

			});
			li1.labelNode.innerHTML = "供应商编码：";
			detail.addChild(li1);

			var li2 = new ListItem({
				rightText:this.item.suppliername ,

			});
			li2.labelNode.innerHTML = "供应商名称：";
			detail.addChild(li2);

			var li6 = new ListItem({
				rightText:this.item.inmoney ,

			});
			li6.labelNode.innerHTML = "订单金额：";
			detail.addChild(li6);

			var li7 = new ListItem({
				rightText:this.item.ordertype ,

			});
			li7.labelNode.innerHTML = "订单类型：";
			detail.addChild(li7);

			var li8 = new ListItem({
				rightText:this.item.inmoney ,

			});
			li8.labelNode.innerHTML = "订单金额：";
			detail.addChild(li8);

			var li9 = new ListItem({
				rightText:this.item.send_at_once==0?"否":"是" ,

			});
			li9.labelNode.innerHTML = "是否越库：";
			detail.addChild(li9);

			var li10 = new ListItem({
				rightText:this.item.willindate!=null?this.item.willindate.substr(0,10):this.item.willindate ,

			});
			li10.labelNode.innerHTML = "预计到货日：";
			detail.addChild(li10);
			var li11 = new ListItem({
				rightText:this.item.enddate!=null?this.item.enddate.substr(0,10):this.item.enddate ,

			});
			li11.labelNode.innerHTML = "订到最后期效：";
			detail.addChild(li11);
			var li13 = new ListItem({
				rightText:this.item.orderflag ,

			});
			li13.labelNode.innerHTML = "订单状态：";
			detail.addChild(li13);
			var li14 = new ListItem({
				rightText:this.item.recorddate!=null?this.item.recorddate.substr(0,10):this.item.recorddate ,

			});
			li14.labelNode.innerHTML = "订货日期：";
			detail.addChild(li14);
			var li15 = new ListItem({
				rightText:this.item.recorder ,

			});
			li15.labelNode.innerHTML = "制单人：";
			detail.addChild(li15);
			var li16 = new ListItem({
				rightText:this.item.senddate!=null?this.item.senddate.substr(0,10):this.item.senddate ,

			});
			li16.labelNode.innerHTML = "发货日期：";
			detail.addChild(li16);
			var li18 = new ListItem({
				rightText:this.item.appointdate!=null?this.item.appointdate.substr(0,10):this.item.appointdate ,

			});
			li18.labelNode.innerHTML = "预约日期：";
			detail.addChild(li18);

			var li19 = new ListItem({
				rightText:this.item.platformdefine ,

			});
			li19.labelNode.innerHTML = "预约月台：";
			detail.addChild(li19);
			var li20 = new ListItem({
				rightText:this.item.timerange ,

			});
			li20.labelNode.innerHTML = "预约时段：";
			detail.addChild(li20);
			var li21 = new ListItem({
				rightText:this.item.traynum

			});
			li21.labelNode.innerHTML = "预约托盘数：";
			detail.addChild(li21);			
			getdetailList(); 
		}
		
		function getdetailList(){
			 var params = {
					 operation:"orderdetail",
					 orderno:orderno
					};

				dojo.xhrGet({
			               url:'<%=ct%>/listOrderAction.do',
						   content : params,
						   handleAs : "json",
						   load : resultCallback,
						   error : resultError
			    });
			function resultCallback(data, ioArgs) {
				var salarylist = registry.byId("ordersgoodslist");
				arr.forEach(salarylist.getChildren(), function(child) {
					salarylist.removeChild(child);
				});
				var li = new ListItem2({
					onClick : "",
					moveTo : "",
					progStyle:"color:black"
				});
				li.labelNode.innerHTML = "<span style='color:black'>商品名称 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 数量&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;单价  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;金额</span>";
				salarylist.addChild(li);
				arr.forEach(data, function(item, i) {
					amount+=item.inmoney;
					var li = new ListItem2({
						onClick : getorderslistDetail,
						moveTo : "orderslistDetail",
						item : item

					});
					li.labelNode.innerHTML = item.gdsname;
					var _d1=domconstruct.create("div",{
	                      style:{
	                         display:"inline"
	                      }
	                });
	                var _span1=domconstruct.create("span");
	                var _span2=domconstruct.create("span",{
	                    style:{
	                        display:"inline",
	                        marginLeft:"30px"
	                     }
	                });
	                var _span3=domconstruct.create("span",{
	                    style:{
	                        display:"inline",
	                        marginLeft:"30px",
	                        color:"red"
	                     }
	                });
	                _span1.innerText=item.amount;
	                _span2.innerText=item.inprice;
	                _span3.innerText=item.inmoney;
	                _d1.appendChild(_span1);_d1.appendChild(_span2);_d1.appendChild(_span3);
	                li.domNode.appendChild(_d1);
					salarylist.addChild(li);
				});
				var li1 = new ListItem({
					onClick : "",
					rightText:amount,
					moveTo : ""
				});
				li1.labelNode.innerHTML ="合计金额: ";
				salarylist.addChild(li1);
			}
			
			function getorderslistDetail(item){
				var detail = registry.byId("ordersdetaillist");
				arr.forEach(detail.getChildren(), function(child) {
					detail.removeChild(child);
				});
				var li = new ListItem({
					rightText:this.item.orderno ,

				});
				li.labelNode.innerHTML = "订单号：";
				detail.addChild(li);

				var li1 = new ListItem({
					rightText:this.item.suppliercode ,

				});
				li1.labelNode.innerHTML = "供应商编码：";
				detail.addChild(li1);

				var li2 = new ListItem({
					rightText:this.item.suppliername ,

				});
				li2.labelNode.innerHTML = "供应商名称：";
				detail.addChild(li2);

				var li6 = new ListItem({
					rightText:this.item.deptcode ,

				});
				li6.labelNode.innerHTML = "订货部门编码";
				detail.addChild(li6);

				var li7 = new ListItem({
					rightText:this.item.deptname ,

				});
				li7.labelNode.innerHTML = "订货部门名称:";
				detail.addChild(li7);

				var li8 = new ListItem({
					rightText:this.item.gdsincode ,

				});
				li8.labelNode.innerHTML = "商品编码：";
				detail.addChild(li8);

				var li9 = new ListItem({
					rightText:this.item.gdsname,

				});
				li9.labelNode.innerHTML = "商品名称：";
				detail.addChild(li9);

				var li10 = new ListItem({
					rightText:this.item.stripecode ,

				});
				li10.labelNode.innerHTML = "条形码：";
				detail.addChild(li10);
				var li11 = new ListItem({
					rightText:this.item.baseunit ,

				});
				li11.labelNode.innerHTML = "基本销售单位：";
				detail.addChild(li11);
				var li13 = new ListItem({
					rightText:this.item.amount ,

				});
				li13.labelNode.innerHTML = "订货数量：";
				detail.addChild(li13);
				var li14 = new ListItem({
					rightText:this.item.inprice ,

				});
				li14.labelNode.innerHTML = "订货价格：";
				detail.addChild(li14);
				var li15 = new ListItem({
					rightText:this.item.inmoney ,

				});
				li15.labelNode.innerHTML = "订货金额：";
				detail.addChild(li15);
				var li16 = new ListItem({
					rightText:this.item.s_no ,

				});
				li16.labelNode.innerHTML = "行号：";
				detail.addChild(li16);
				
			}
		}
		    //错误提示
		       function resultError(data, ioArgs) {
		            var Node=document.getElementById("neworderlist");
		             var listItem=document.createElement("li");
				     listItem.innerHTML=("网络异常!请重新操作!"); //使用占位符
				     Node.appendChild(listItem);
		       }

				function resultCalldetail(data,ioArgs) {
					var detail = registry.byId("ordersdetail");
					// remove anything from previous selected stock
					arr.forEach(detail.getChildren(), function(child){
						detail.removeChild(child);
					});
					arr.forEach(data, function(item){
						var li = new ListItem({
							onClick: getdetail,
							moveTo: "orderDetail",
							rightText:item.inmoney,
							icon:'img/tab-icon-11h.png',
							item:item

						});
						li.labelNode.innerHTML = item.gdsname;
						detail.addChild(li);
					});
		   	}
	});

		function getDate(node, v){
			if(v === true){ // Done clicked
				node.value = dijit.byId("spin1").get("values").join('-');
			}
		}
		function setDate(node){
			var v = node.value.split(/-/);
			if(v.length == 3){
				var w = dijit.byId("spin1");
				w.set("values", v);
			}
		}
		
		require([
		         "dijit/registry",
		         "dojo/_base/array",
		         "dojox/mobile/ViewController",
		         "dojox/mobile/ListItem",
		         "dojox/mobile/parser",
		         "dojox/mobile",
		         "dojox/mobile/Button",
		         "dojox/mobile/ExpandingTextArea"
		     ], function(registry,arr, ViewController,ListItem){
				 onBtn2Clicked=function(e){
					 registry.byId("searchview").performTransition("home", 1, "slide");
				 }
		         onBtn1Clicked = function(e){

					
					function resultError(data, ioArgs) {
						var Node = document.getElementById("neworderlist");
						var listItem = document.createElement("li");
						listItem.innerHTML = ("网络异常!请重新操作!"); //使用占位符
						Node.appendChild(listItem);
					}
					registry.byId("orderDetail").performTransition("orderslist", 1, "slide");
				};
			});
	</script>
</head>
<body>
	<div style="display: block" id="loading"></div>
	<div id="maincontent" style="display: none">
		<div id="home" data-dojo-type="dojox.mobile.View"
			data-dojo-props="selected: true">
			<h1 data-dojo-type="dojox.mobile.Heading" label="新订单列表">
				<span data-dojo-type="dojox.mobile.ToolBarButton"
					data-dojo-props='icon:"mblDomButtonWhiteSearch"'
					style="float: right;" id="searchbutton"></span>
			</h1>
			<ul data-dojo-type="dojox.mobile.RoundRectList" id="neworderlist">
			</ul>
		</div>

		<div id="orderDetail" data-dojo-type="dojox.mobile.View">
			<h1 data-dojo-type="dojox.mobile.Heading"
				data-dojo-props="back:'订单列表', moveTo:'home'">订单明细</h1>
			<ul data-dojo-type="dojox.mobile.RoundRectList" id="detail">
			</ul>
			<!--  <div class="buttoncellwrapper">
			<button data-dojo-type="dojox/mobile/Button"
				class="mblButton baseBtn whiteBtn itemcell" id="mybutton"
				style="-webkit-user-select: none;"
				data-dojo-props='onClick:onBtn1Clicked'>查看商品明细</button>
		</div>-->
			<div
				style="margin-left: 50px; margin-top: 50px; margin-left: 10px; font-size: 22px; color: rgb(44, 44, 46); font-variant: small-caps;">订单商品明细列表</div>
			<ul data-dojo-type="dojox.mobile.RoundRectList" id="ordersgoodslist">
			</ul>
		</div>

		<div id="orderslist" data-dojo-type="dojox.mobile.View">
			<h1 data-dojo-type="dojox.mobile.Heading"
				data-dojo-props="back:'订单明细', moveTo:'orderDetail'">订单商品明细列表</h1>

		</div>

		<div id="orderslistDetail" data-dojo-type="dojox.mobile.View">
			<h1 data-dojo-type="dojox.mobile.Heading"
				data-dojo-props="back:'订单列表', moveTo:'orderDetail'">订单商品明细</h1>
			<ul data-dojo-type="dojox.mobile.RoundRectList" id="ordersdetaillist">
			</ul>
		</div>

		<div id="searchview" data-dojo-type="dojox.mobile.View"
			data-dojo-props="selected: true">
			<h1 data-dojo-type="dojox.mobile.Heading"
				data-dojo-props="back:'订单列表', moveTo:'home'">订单查询</h1>

				<div class="itemcellwrapper">
					<label class="mblLabel">订单号:</label> <input id="detail_todo1"
						class="mblTextArea mblExpandingTextArea itemcell"
						placeholder="请输入订单号" tabindex="0" widgetid="detail_todo" value="">
					<label class="mblLabel">开始时间:</label>
					<input id="detail_todo2"
						class="mblTextArea mblExpandingTextArea itemcell"
						placeholder="Title" tabindex="0" widgetid="detail_todo"
						value="订货时间" readOnly
						onclick="dijit.byId('datePicker').show(this, ['above-centered','below-centered','after','before'])"/>
					<label class="mblLabel">结束时间:</label>
					<input id="detail_todo3"
						class="mblTextArea mblExpandingTextArea itemcell"
						placeholder="Title" tabindex="0" widgetid="detail_todo4"
						value="订货时间" readOnly
						onclick="dijit.byId('datePicker').show(this, ['above-centered','below-centered','after','before'])"/>
					<button id="deleteCurrentItem" data-dojo-type="dojox/mobile/Button"
						class="mblButton baseBtn mblRedButton itemcell" tabindex="0"
						widgetid="deleteCurrentItem" style="-webkit-user-select: none;"
						data-dojo-props='onClick:onBtn2Clicked'>查询</button>
				</div>
		</div>
	</div>
	<div id="datePicker" data-dojo-type="dojox.mobile.Opener"
		data-dojo-props="onHide:getDate, onShow:setDate">
		<h1 dojoType="dojox.mobile.Heading" label="选择时间">
			<span dojoType="dojox.mobile.ToolBarButton" label="完成"
				class="mblColorBlue"
				style="position: absolute; width: 45px; right: 0;"
				onclick="dijit.byId('datePicker').hide(true)"></span> <span
				dojoType="dojox.mobile.ToolBarButton" label="取消"
				class="mblColorBlue"
				style="position: absolute; width: 45px; left: 0;"
				onclick="dijit.byId('datePicker').hide(false)"></span>
		</h1>
		<div id="spin1" data-dojo-type="dojox/mobile/SpinWheelDatePicker"></div>
	</div>
</body>
</html>